#pragma once

#include "LiteralReal.h"


namespace uml {

const double LiteralReal::value_default_ = 0.0;
LiteralReal::LiteralReal(const QString& umlType)
    : LiteralSpecification(umlType) {}

void LiteralReal::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    LiteralSpecification::fromJson(json, errorList);
    value_ = json.value("value").toDouble(value_default_);
}

void LiteralReal::toJson(QJsonObject& json) {
    LiteralSpecification::toJson(json);
    if (value_ != value_default_) {
        json.insert("value", value_);
    }
}

/// <summary>
/// isComputable
    /// The query isComputable() is redefined to be true.
/// </summary>
    /// <code>
    /// result = (true)
    /// </code>
bool LiteralReal::isComputable() const
{
    return false;
}

/// <summary>
/// realValue
    /// The query realValue() gives the value.
/// </summary>
    /// <code>
    /// result = (value)
    /// </code>
double LiteralReal::realValue() const
{
    return 0.0;
}

/// <summary>
/// value getter
/// The specified Real value.
/// </summary>
double LiteralReal::value() const {
    return value_;
}

/// <summary>
/// value setter
/// The specified Real value.
/// </summary>
void LiteralReal::setValue(double value) {
    value_ = value;
}

} // namespace uml
